<?php set_include_path("include");?>
<?php require_once 'include/model/Event.php';?>
<?php require_once 'model/Registration.php';?>
<?php require_once 'util/helperFunctions.php';?>

<?php
$incpath = "a_includes/";
include $incpath.'admincheck.php'; 
$page = isset($_GET['p']) ? $_GET['p'] : null;
$eventid = isset($_GET['evt']) ? $_GET['evt'] : null;

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="robots" content="noindex, nofollow">
        <title>Admin</title>
        <link href="CSS/style_sifaka.css" rel="stylesheet" type="text/css"/>
        <link href="<?php echo $incpath; ?>/css/demo_table_jui.css" rel="stylesheet" type="text/css"/>
        <script src='<?php echo $incpath."js/jquery-1.5.1.min.js"; ?>'></script><!-- http://code.jquery.com/jquery-latest.js -->
        <link type="text/css" href="<?php echo $incpath; ?>css/smoothness/jquery-ui-1.8.14.custom.css" rel="stylesheet" />	
		
		<style>
		    .lightbox_bg {
		        background:#000 none repeat scroll 0 0;
		        display:none;
		        height:800px;
		        left:0;
		        filter:alpha(opacity=50);
		        opacity: 0.5;
		        top:0;
		        width:100%;
		        z-index:10;
		        display:none;
		        position:fixed;
		    }
    	</style>
		
		<script type="text/javascript" src="<?php echo $incpath; ?>js/jquery-ui-1.8.14.custom.min.js"></script>
        
        <script type="text/javascript" language="javascript" src="<?php echo $incpath; ?>/jquery.dataTables.js"></script>
		<script type="text/javascript" charset="utf-8">
			$(document).ready(function() {
				$('#data').dataTable({
					"bJQueryUI": true,
					"bStateSave": true,
					"sPaginationType": "full_numbers"
				});
			} );
		</script>
		<script type="text/javascript">
			function copy(tableid) {
				alert('De tekst is reeds geselecteerd, druk na dit scherm op Ctrl+C om alles te kopieren en in Excel met Ctrl+V alles te plakken.');
				//$('<div id="lightb"/>').addClass('lightbox_bg').appendTo('body').show();
				var table = document.getElementById(tableid);
				var text = table.innerHTML;
				text = text.replace(/\t/gi, "");
				text = text.replace(/\n/gi, "");
				text = text.replace(/<table>/gi, "");
				text = text.replace(/<\/table>/gi, "");
				text = text.replace(/<thead>/gi, "");
				text = text.replace(/<\/thead>/gi, "");
				text = text.replace(/<tbody>/gi, "");
				text = text.replace(/<\/tbody>/gi, "");
				text = text.replace(/<th>/gi, "");
				text = text.replace(/<\/th>/gi, "\t");
				text = text.replace(/<tr>/gi, "");
				text = text.replace(/<\/tr>/gi, "\n");
				text = text.replace(/<td>/gi, "");
				text = text.replace(/<\/td>/gi, "\t");
				var textarea = document.getElementById('textspace');
				textarea.innerHTML = text;
				$('#copydiv').show();
				textarea.focus();
				textarea.select();
			}
			function closeCopy() {
				$('#lightb').remove();
				document.getElementById('textspace').innerHTML = "";
				$('#copydiv').hide();
			}
		</script>
		<script type="text/javascript">
	        function coy() {
	            //add modal background
	            $('<div />').addClass('lightbox_bg').appendTo('body').show();
	            //add modal window
	            $('<div />').text('I am your modal example').addClass('modal').appendTo('body');
	        };
    </script>
    </head>
    <body> 
		<div id="copydivcont">
			<div id="copydiv">
				<h2 style="color: white; float:right;">Sluit dit scherm hier: <input style="padding:0.2em 0.6em;" type="button" value="Sluiten" onclick="javascript:closeCopy();"/></h2>
				<textarea id="textspace"></textarea>
			</div>
		</div>
		<script type="text/javascript">
			$('#copydiv').hide();
		</script>
	    <div class="main">
			<div class="container">
				<?php if (!isset($eventid)) {?>
		    	<h3>Kies een evenement</h3>
		    	<div id="listcontainer">
		    	<ul id="navlist">
		    		<li><a href="?evt=all">Alle evenementen</a></li>
		    		<?php 
		    		foreach (Event::getAllEvents() as $event) {
		    		?>
		            	<li><a href="?evt=<?php echo $event->getId();?>"><?php echo $event->getName();?></a></li>
		            <?php 
		    		}
		    		?>
		    	</ul>
	            </div>
		    	<?php } else { ?>
		    	<div id="menucontainer">
			    	<ul id="menulist">
				    	<li><a href="?evt=<?php echo $eventid;?>&p=regs">Inschrijvingen</a></li>
				    	<li><a href="?evt=<?php echo $eventid;?>&p=muli">Multiple input</a></li>
				    	<li><a href="?evt=<?php echo $eventid;?>&p=stat">Statistieken</a></li>
				    	<li><a href="?evt=<?php echo $eventid;?>&p=list">Aanwezigheidslijst</a></li>
				    	<li><a href="?">&lt;&lt; Terug</a></li>
			    	</ul>
		    	</div>
		    	<?php }
		    		if (isset($eventid) && isset($page)) {
		    			switch($page) {
		    				case "regs":
		    					include($incpath."regs.php");
		    				break;
		    				
		    				case "muli":
		    					include($incpath."multi-input.php");
		    				break;
		    					
		    				case "stat":
		    					include($incpath."stat.php");
		    				break;
		    				
		    				case "list":
		    					include($incpath."list.php");
		    				break;
		    				
		    				default:
		    					include($incpath."regs.php");
		    			}
		    		} else if (isset($eventid) && !isset($page)) {
		    			include($incpath."regs.php");
		    		}
		        ?>
		        <div class="myfooter">-- by sifaka</div>
	        </div>
        </div>
    </body>
</html>